package com.acme.task1;

public class Calculator {
	public static void main(String[] args) {
        if (args.length < 3) {
            System.err.println("wrong number of arguments");
            return;
        }

        double operand1, operand2;
        try {
            operand1 = Double.parseDouble(args[0]);
            operand2 = Double.parseDouble(args[2]);
        } catch (NumberFormatException e) {
            System.err.println("wrong operands");
            return;
        }

        if (args[1].length() > 1) {
            System.err.println("wrong operation");
            return;
        }

        //Array type expected
        //args[1][0]

        int operation = args[1].charAt(0);
        double result;
        switch (operation) {
            case '+':
                result = operand1 + operand2;
                break;
            case '-':
                result = operand1 - operand2;
                break;
            case '*':
                result = operand1 * operand2;
                break;
            case '/':
                if (operand2 == 0) {
                    System.err.println("division by zero");
                    return;
                }
                result = operand1 / operand2;
                break;
            default:
                System.err.println("wrong operation");
                return;
        }

		System.out.println(result);
		

	}
}
